<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:security="http://www.springframework.org/security/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">定时任务定义</ui:define>
    <ui:define name="content">
        <h:form>
            <div class="topbar clearfix"
                 style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="right">
                        <p:commandButton value="编辑" icon="fa fa-edit"
                                         actionListener="#{scheduleDefinitionInfoBean.changeStatusToEdit}"
                                         process="@this"
                                         update="@form"
                                         rendered="#{scheduleDefinitionInfoBean.isView() and security:areAllGranted('DICTIONARY_EDIT')}"/>
                        <p:commandButton value="保存" icon="fa fa-save"
                                         actionListener="#{scheduleDefinitionInfoBean.onSave}"
                                         rendered="#{scheduleDefinitionInfoBean.isNotView() and security:areAnyGranted('DICTIONARY_EDIT,DICTIONARY_ADD')}"
                                         update="@form"/>
                        <p:commandButton value="取消" icon="fa fa-reply"
                                         actionListener="#{scheduleDefinitionInfoBean.changeStatusToView}"
                                         rendered="#{scheduleDefinitionInfoBean.isEdit()}"
                                         process="@this"
                                         update="@form"/>
                        <p:button value="返回" icon="fa fa-reply-all" href="#{currentUserBean.back}"></p:button>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">
                        <div class="card">
                            <div class="ui-g">
                                <div class="ui-g-12"><h3><b>定时任务信息</b></h3></div>
                                <div class="ui-g-2">
                                    <p:outputLabel for="taskName" value="任务名称"/>
                                </div>
                                <div class="ui-g-4">
                                    <p:inputText id="taskName"
                                                 value="#{scheduleDefinitionInfoBean.$.taskName}"
                                                 disabled="#{scheduleDefinitionInfoBean.isView()}"/>
                                </div>
                                <div class="ui-g-2">
                                    <p:outputLabel for="taskGroup" value="任务分组"/>
                                </div>
                                <div class="ui-g-4">
                                    <p:selectOneMenu id="taskGroup"
                                                     value="#{scheduleDefinitionInfoBean.$.taskGroup}"
                                                     filter="true"
                                                     filterMatchMode="contains"
                                                     disabled="#{scheduleDefinitionInfoBean.isView()}">
                                        <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                        <f:selectItems
                                                value="#{scheduleDefinitionInfoBean.dictionaries[DictionaryCode.SCHEDULE_TASK_GROUP]}"
                                                var="dic"
                                                itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                                    </p:selectOneMenu>
                                </div>
                                <div class="ui-g-2">
                                    <p:outputLabel for="startType" value="启动方式"/>
                                </div>
                                <div class="ui-g-4">
                                    <p:selectOneMenu id="startType"
                                                     value="#{scheduleDefinitionInfoBean.$.startType}"
                                                     filter="true"
                                                     filterMatchMode="contains"
                                                     disabled="#{scheduleDefinitionInfoBean.isView()}">
                                        <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                        <f:selectItems
                                                value="#{scheduleDefinitionInfoBean.dictionaries[DictionaryCode.SCHEDULE_START_TYPE]}"
                                                var="dic"
                                                itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                                    </p:selectOneMenu>
                                </div>
                                <div class="ui-g-2">
                                    <p:outputLabel for="cron" value="CRON表达式"/>
                                </div>
                                <div class="ui-g-4">
                                    <p:inputText id="cron" value="#{scheduleDefinitionInfoBean.$.cron}"
                                                 disabled="#{scheduleDefinitionInfoBean.isView()}"/>
                                </div>
                                <div class="ui-g-2">
                                    <p:outputLabel for="executeType" value="执行方式"/>
                                </div>
                                <div class="ui-g-4">
                                    <p:selectOneMenu id="executeType"
                                                     value="#{scheduleDefinitionInfoBean.$.executeType}"
                                                     filter="true"
                                                     filterMatchMode="contains"
                                                     disabled="#{scheduleDefinitionInfoBean.isView()}">
                                        <p:ajax event="change" update="taskAndScriptLabel taskAndScriptContent"/>
                                        <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                        <f:selectItems
                                                value="#{scheduleDefinitionInfoBean.dictionaries[DictionaryCode.SCHEDULE_EXECUTE_TYPE]}"
                                                var="dic"
                                                itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                                    </p:selectOneMenu>
                                </div>
                                <div class="ui-g-6"/>
                                <div class="ui-g-2">
                                    <h:panelGroup id="taskAndScriptLabel">
                                        <p:outputLabel for="taskCls" value="任务类"
                                                       rendered="#{scheduleDefinitionInfoBean.$.executeType == 0}"/>
                                        <p:outputLabel for="script" value="Groovy脚本"
                                                       rendered="#{scheduleDefinitionInfoBean.$.executeType == 1}"/>
                                    </h:panelGroup>
                                </div>
                                <div class="ui-g-10">
                                    <h:panelGroup id="taskAndScriptContent">
                                        <p:inputTextarea id="script" value="#{scheduleDefinitionInfoBean.$.script}"
                                                         disabled="#{scheduleDefinitionInfoBean.isView()}"
                                                         rendered="#{scheduleDefinitionInfoBean.$.executeType == 1}"/>
                                        <p:inputText id="taskCls" value="#{scheduleDefinitionInfoBean.$.taskCls}"
                                                     disabled="#{scheduleDefinitionInfoBean.isView()}"
                                                     rendered="#{scheduleDefinitionInfoBean.$.executeType == 0}"/>
                                    </h:panelGroup>
                                </div>
                                <div class=" ui-g-2">
                                    <p:outputLabel for="remark" value="备注"/>
                                </div>
                                <div class="ui-g-4">
                                    <p:inputTextarea id="remark" value="#{scheduleDefinitionInfoBean.$.remark}"
                                                     disabled="#{scheduleDefinitionInfoBean.isView()}"/>
                                </div>
                                <div class="ui-g-2">
                                    <p:outputLabel for="enable" value="是否启用"/>
                                </div>
                                <div class="ui-g-4">
                                    <p:inputSwitch id="enable" onLabel="是" offLabel="否"
                                                   value="#{scheduleDefinitionInfoBean.$.enable}"
                                                   disabled="#{scheduleDefinitionInfoBean.isView()}"/>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>